package com.tju.resource.tool.bcrypt;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * 明文加密
 *
 * @USER: CLS
 */
@Component
public class BCryptPasswordEncoderUtil extends BCryptPasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return super.encode(rawPassword);
    }

    /**
     * 密码对比
     *
     * @param rawPassword
     * @param encodedPassword
     * @return
     */
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return super.matches(rawPassword, encodedPassword);
    }

    /**
     * BCrypt加密
     *
     * @param msg
     * @return
     */
    public static String encrypt(String msg) {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        return passwordEncoder.encode(msg);
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder encode = new BCryptPasswordEncoder();
    }
}
